
/**
 * Date:2019年6月12日上午10:20:04
 * Copyright (c) 2019, www.bwbroad.com All Rights Reserved.
 *
*/

package com.xue.im.client.ui;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

import org.apache.commons.text.StringEscapeUtils;

/**
 * Description: TODO <br/>
 * Date: 2019年6月12日 上午10:20:04 <br/>
 * 
 * @author xuejianxin
 */
public class JEditorPane3 {
	public static void main(String[] args) {
		JEditorPane editPane = null;
		try {
			// URL address = new URL("http://www.sina.com.cn");
			// editPane = new JEditorPane(address);
			//String str = new String("This is a test.\nthis is Line2!\nThis is Line 3!");
			// editPane = new JEditorPane("text/plain", str);
			// 直接显示文本
			// editPane = new JEditorPane("text/html","<h1>33333</h1>");
			editPane = new JEditorPane();
			editPane.setContentType("text/html");
			editPane.setText("<h1 color='red'>44444</h1><br/>"
					+ StringEscapeUtils.escapeHtml4("java 5<10  <h1 color='red'>5555</h1>"));

		} catch (Exception e) {
			System.out.println("IOException:" + e);
		}
		editPane.setEditable(false);
		JFrame f = new JFrame("JEditorPane3");
		f.setContentPane(new JScrollPane(editPane));
		f.setSize(200, 250);
		f.setVisible(true);
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
}
